package pers.jason.wppm.api.support;

import lombok.Data;

import java.io.Serializable;

/**
 *
 */
@Data
public class ResultView implements Serializable  {

    private Result result;

    private String message;

    private Object obj;

    private ResultView() {}

    private ResultView(String message) {
        this.message = message;
    }

    private ResultView(String message, Object obj) {
        this.message = message;
        this.obj = obj;
    }

    private ResultView(Object obj) {
        this.obj = obj;
    }

    public static ResultView success() {
        ResultView resultView = new ResultView();
        resultView.setResult(Result.success);
        return resultView;
    }

    public static ResultView success(String message) {
        ResultView resultView = new ResultView(message);
        resultView.setResult(Result.success);
        return resultView;
    }

    public static ResultView success(String message, Object obj) {
        ResultView resultView = new ResultView(message, obj);
        resultView.setResult(Result.success);
        return resultView;
    }

    public static ResultView failure() {
        ResultView resultView = new ResultView();
        resultView.setResult(Result.failure);
        return resultView;
    }

    public static ResultView failure(String message) {
        ResultView resultView = new ResultView(message);
        resultView.setResult(Result.failure);
        return resultView;
    }

    public static ResultView failure(String message, Object obj) {
        ResultView resultView = new ResultView(message, obj);
        resultView.setResult(Result.failure);
        return resultView;
    }

    public static ResultView failure(Object obj) {
        ResultView resultView = new ResultView(obj);
        resultView.setResult(Result.failure);
        return resultView;
    }

    public static ResultView success(Object obj) {
        ResultView resultView = new ResultView(obj);
        resultView.setResult(Result.success);
        return resultView;
    }



    public String getResult() {
        return result.getResult();
    }

    public void setResult(Result result) {
        this.result = result;
    }

    public enum Result {
        success {
            public String getResult() {
                return "success";
            }
        },
        failure {
            public String getResult() {
                return "failure";
            }
        };

        public abstract String  getResult();


    }

}
